package com.ruoyi.bigdata.controller;

import com.ruoyi.bigdata.domain.vo.ZipInfo;
import com.ruoyi.bigdata.service.DataWorkService;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;


@RestController
@RequestMapping("/dataWorks")
public class DataWorksController {
    private static final Logger log = LoggerFactory.getLogger(DataWorksController.class);

    @RequiresPermissions("system:config:list")
    @PostMapping("/parse")
    public AjaxResult list(@RequestParam("file") MultipartFile file) {
        try {
            List<ZipInfo> list = DataWorkService.parseZipFile(file);
            return AjaxResult.success(list);
        } catch (Exception e) {
            log.error("文件解析失败", e);
            return AjaxResult.error("文件解析失败");
        }

    }
}
